package com.alisiwei.core.spring;

import javax.servlet.ServletContextEvent; 
import javax.servlet.ServletContextListener;
import org.springframework.context.ApplicationContext; 
import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 描述：非@Controller使用Service类
 * 作者：zhangkai
 * 日期：2017-8-28
 */
public class SpringInit implements ServletContextListener {
    private static WebApplicationContext springContext;    
    public SpringInit() {
    	super();  
    }
    public void contextInitialized(ServletContextEvent event) {
    	springContext = WebApplicationContextUtils.getWebApplicationContext(event.getServletContext());   
    }    

    public void contextDestroyed(ServletContextEvent event) {     

    }    

    public static ApplicationContext getApplicationContext() {
    	return springContext;    
    }
}
